package com.ng.framework.view.desktop.filters;

import javax.swing.JTextField;

import org.apache.commons.lang.StringUtils;

import com.ng.framework.persistence.NGSearchParameter.Type;
import com.ng.framework.persistence.NGSearchParameter.UnaryOperation;

public class NGTextFieldFilter extends NGSimpleFilter<JTextField> {

	private static final long serialVersionUID = 4732544242112452811L;

	public NGTextFieldFilter(String name, Class<?> clazz, String attribute, Type type, UnaryOperation unaryOperation) {
		super(name, clazz, attribute, type, unaryOperation);
	}
	
	public NGTextFieldFilter(String name, Class<?> clazz, String attribute, Type type, UnaryOperation unaryOperation,
			String joinAttribute) {
		super(name, clazz, attribute, type, unaryOperation, joinAttribute);

	}

	@Override
	protected JTextField createComponent() {
		return new JTextField();
	}

	@Override
	protected String getComponentValue(JTextField textField) {
		return StringUtils.isBlank(textField.getText()) ? null : textField.getText();
	}
	
	@Override
	public void clear() {
		this.getComponent().setText(null);
	}

}
